﻿using System.IO;
using System.Text;
using ClieOp;
using NUnit.Framework;

namespace ClieOpTest
{
    [TestFixture]
    internal class ParsePostTest
    {
        [Test]
        public void BusinessPaymentPostTest()
        {
            var post1 = new Post(12.34m, 786892692, "Roel van der Steen", "abcdefghij", Post.PaymentType.CreditorBusinessPayment);
            post1.AddOmschrijving("foo bar");
            post1.AddOmschrijving("baoo bah");
            var memorystream = new MemoryStream(Encoding.Default.GetBytes(post1.ToString()));
            var reader = new ClieOpReader(memorystream);
            Post post2 = Post.Parse(reader);
            Assert.AreEqual(post1.BedragEur, post2.BedragEur);
            Assert.AreEqual(post1.Rekeningnummerbegunstigde, post2.Rekeningnummerbegunstigde);
            Assert.AreEqual(post1.Rekeningnummerbetaler, post2.Rekeningnummerbetaler);
            Assert.AreEqual(post1.PostPaymentType, post2.PostPaymentType);
            Assert.AreEqual(post1.Omschrijvingen[1], post2.Omschrijvingen[1]);
        }

        [Test]
        public void DirectDebitPostTest()
        {
            var post1 = new Post(12.34m, 786892692, "Roel van der Steen", "abcdefghij");
            post1.AddOmschrijving("foo bar");
            var memorystream = new MemoryStream(Encoding.Default.GetBytes(post1.ToString()));
            var reader = new ClieOpReader(memorystream);
            Post post2 = Post.Parse(reader);
            Assert.AreEqual(post1.BedragEur, post2.BedragEur);
            Assert.AreEqual(post1.Rekeningnummerbegunstigde, post2.Rekeningnummerbegunstigde);
            Assert.AreEqual(post1.Rekeningnummerbetaler, post2.Rekeningnummerbetaler);
            Assert.AreEqual(post1.PostPaymentType, post2.PostPaymentType);
            Assert.AreEqual(post1.Omschrijvingen[0], post2.Omschrijvingen[0]);
        }
    }
}